package com.ruoyi.web.controller.system;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.CarAccept;
import com.ruoyi.system.service.ICarAcceptService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 车辆验收Controller
 * 
 * @author ruoyi
 * @date 2024-09-09
 */
@RestController
@RequestMapping("/system/accept")
public class CarAcceptController extends BaseController
{
    @Autowired
    private ICarAcceptService carAcceptService;

    /**
     * 查询车辆验收列表
     */
    @PreAuthorize("@ss.hasPermi('system:accept:list')")
    @GetMapping("/list")
    public TableDataInfo list(CarAccept carAccept)
    {
        startPage();
        List<CarAccept> list = carAcceptService.selectCarAcceptList(carAccept);
        return getDataTable(list);
    }

    /**
     * 导出车辆验收列表
     */
    @PreAuthorize("@ss.hasPermi('system:accept:export')")
    @Log(title = "车辆验收", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CarAccept carAccept)
    {
        List<CarAccept> list = carAcceptService.selectCarAcceptList(carAccept);
        ExcelUtil<CarAccept> util = new ExcelUtil<CarAccept>(CarAccept.class);
        util.exportExcel(response, list, "车辆验收数据");
    }

    /**
     * 获取车辆验收详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:accept:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(carAcceptService.selectCarAcceptById(id));
    }

    /**
     * 新增车辆验收
     */
    @PreAuthorize("@ss.hasPermi('system:accept:add')")
    @Log(title = "车辆验收", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CarAccept carAccept)
    {
        return toAjax(carAcceptService.insertCarAccept(carAccept));
    }

    /**
     * 修改车辆验收
     */
    @PreAuthorize("@ss.hasPermi('system:accept:edit')")
    @Log(title = "车辆验收", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CarAccept carAccept)
    {
        return toAjax(carAcceptService.updateCarAccept(carAccept));
    }

    /**
     * 删除车辆验收
     */
    @PreAuthorize("@ss.hasPermi('system:accept:remove')")
    @Log(title = "车辆验收", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(carAcceptService.deleteCarAcceptByIds(ids));
    }
}
